package cn.gson.crm.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Table(name="ORDERO_")
@Entity
public class Order {
    private long orderId;
    private String orderNumber;
    private Long orderMoney;
    private Timestamp orderTime;
    private String orderDesc;
    private Long ereApprover;
    private String ecrState;
    private String period;
    private  Integer orderCharge;
    private Integer orderNumbers;
    private Contract contractByContractId;
    private Employee employee;
    private Employee employee2;
    private Long refundAmont;
    private Timestamp orderLasttime;
    private String orderTuifou;
    private String orderfuqinfou;
    private List<OrderDetails> orderDetailsList;

    @Column(name = "order_tuifou")
    public String getOrderTuifou() {
        return orderTuifou;
    }

    public void setOrderTuifou(String orderTuifou) {
        this.orderTuifou = orderTuifou;
    }

    @Column(name = "ORDER_FUQINFOU")
    public String getOrderfuqinfou() {
        return orderfuqinfou;
    }

    public void setOrderfuqinfou(String orderfuqinfou) {
        this.orderfuqinfou = orderfuqinfou;
    }
    @OneToMany(mappedBy = "orderByOrderId")
    public List<OrderDetails> getOrderDetailsList() {
        return orderDetailsList;
    }

    public void setOrderDetailsList(List<OrderDetails> orderDetailsList) {
        this.orderDetailsList = orderDetailsList;
    }

    @Basic
    @Column(name = "ORDER_LATESTTIME")
    public Timestamp getOrderLasttime() {
        return orderLasttime;
    }

    public void setOrderLasttime(Timestamp orderLasttime) {
        this.orderLasttime = orderLasttime;
    }

    @Basic
    @Column(name = "REFUND_AMOUNT")
    public Long getRefundAmont() {
        return refundAmont;
    }

    public void setRefundAmont(Long refundAmont) {
        this.refundAmont = refundAmont;
    }

    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "ORDER_CHARGE",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee() {
        return employee;
    }

    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

    @ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},optional=false)//可选属性optional=false,表示author不能为空。删除文章，不影响用户
    @JoinColumn(name = "ERE_APPROVER",insertable = false,updatable = false)//设置在article表中的关联字段(外键)
    public Employee getEmployee2() {
        return employee2;
    }

    public void setEmployee2(Employee employee2) {
        this.employee2 = employee2;
    }

    @Id
    @Column(name = "order_id")
    @GeneratedValue(generator = "seq",strategy = GenerationType.SEQUENCE)
    //定义一个序列生成器
    @SequenceGenerator(name = "seq",sequenceName = "crm",
            initialValue = 1,allocationSize = 1)
    public long getOrderId() {
        return orderId;
    }

    public void setOrderId(long orderId) {
        this.orderId = orderId;
    }
    @Basic
    @Column(name = "ORDER_CHARGE")
    public Integer getOrderCharge() {
        return orderCharge;
    }

    public void setOrderCharge(Integer orderCharge) {
        this.orderCharge = orderCharge;
    }

    @Basic
    @Column(name = "order_number")
    public String getOrderNumber() {
        return orderNumber;
    }

    public void setOrderNumber(String orderNumber) {
        this.orderNumber = orderNumber;
    }

    @Basic
    @Column(name = "order_money")
    public Long getOrderMoney() {
        return orderMoney;
    }

    public void setOrderMoney(Long orderMoney) {
        this.orderMoney = orderMoney;
    }

    @Basic
    @Column(name = "order_time")
    public Timestamp getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Timestamp orderTime) {
        this.orderTime = orderTime;
    }


    @Basic
    @Column(name = "order_desc")
    public String getOrderDesc() {
        return orderDesc;
    }

    public void setOrderDesc(String orderDesc) {
        this.orderDesc = orderDesc;
    }

    @Basic
    @Column(name = "ere_approver")
    public Long getEreApprover() {
        return ereApprover;
    }

    public void setEreApprover(Long ereApprover) {
        this.ereApprover = ereApprover;
    }

    @Basic
    @Column(name = "ecr_state")
    public String getEcrState() {
        return ecrState;
    }

    public void setEcrState(String ecrState) {
        this.ecrState = ecrState;
    }

    @Basic
    @Column(name = "period")
    public String getPeriod() {
        return period;
    }

    public void setPeriod(String period) {
        this.period = period;
    }

    @Basic
    @Column(name = "order_numbers")
    public Integer getOrderNumbers() {
        return orderNumbers;
    }

    public void setOrderNumbers(Integer orderNumbers) {
        this.orderNumbers = orderNumbers;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Order order = (Order) o;
        return orderId == order.orderId &&
                Objects.equals(orderNumber, order.orderNumber) &&
                Objects.equals(orderMoney, order.orderMoney) &&
                Objects.equals(orderTime, order.orderTime) &&

                Objects.equals(orderDesc, order.orderDesc) &&
                Objects.equals(ereApprover, order.ereApprover) &&
                Objects.equals(ecrState, order.ecrState) &&
                Objects.equals(period, order.period) &&
                Objects.equals(orderNumbers, order.orderNumbers);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderId, orderNumber, orderMoney, orderTime,  orderDesc, ereApprover, ecrState, period, orderNumbers);
    }

    @ManyToOne
    @JoinColumn(name = "contract_id", referencedColumnName = "contract_id")
    public Contract getContractByContractId() {
        return contractByContractId;
    }

    public void setContractByContractId(Contract contractByContractId) {
        this.contractByContractId = contractByContractId;
    }

    @Override
    public String toString() {
        return "Order{" +
                "orderId=" + orderId +
                ", orderNumber=" + orderNumber +
                ", orderMoney=" + orderMoney +
                ", orderTime=" + orderTime +
                ", orderDesc='" + orderDesc + '\'' +
                ", ereApprover=" + ereApprover +
                ", ecrState='" + ecrState + '\'' +
                ", period='" + period + '\'' +
                ", orderCharge=" + orderCharge +
                ", orderNumbers=" + orderNumbers +
                ", contractByContractId=" + contractByContractId +
                ", employee=" + employee +
                ", employee2=" + employee2 +
                ", refundAmont=" + refundAmont +
                ", orderLasttime=" + orderLasttime +
                ", orderTuifou='" + orderTuifou + '\'' +
                ", orderDetailsList=" + orderDetailsList +
                '}';
    }
}
